﻿@model VietPremier.EntityImageDestination

@{
    ViewBag.Title = "Insert";
    Layout = "~/Areas/AdminCP/Views/Shared/AdminLayout.cshtml";
}

<script type="text/javascript" src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-1.7.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-ui-1.8.16.custom.min.js")"></script>
<script type="text/javascript">
    jQuery(document).ready(function () {

        $('#nofSuccess').hide(); // an thong bao
        $('#nofError').hide();

        readyValue();
    }); 

    function alertMsg(msg) {
        $('#nofSuccess').hide();
        $('#nofError').show();
        $('#msgNofError').text(msg);
    }
   
    function checkField() {       
        var image = $("#Image").val();
        if (image == null || image == "") {

        }
        else {
            var ext = image.substring((Math.max(0, image.lastIndexOf(".")) || image.length) + 1);
            ext = ext.toLowerCase();

            if (ext != "jpg" && ext != "jpeg" && ext != "gif" && ext != "png") {

                msg = "! Upload an image file with format jpg, jpeg, gif or png";
                alertMsg(msg);
                $("#Image").css("border", "1px solid red");
                return false;
            }
        }
        return confirm("Bạn có muốn tiếp tục thêm mới?");
    }
  
</script>
<div class="maincontentinner">

    <ul class="maintabmenu">
       <li ><a href="@Url.Action("Index", "AdminImageDestination", new { id = @ViewBag.IdDestination })" >Quản lý hình ảnh điểm đến</a></li>
        <li class="current"><a href="@Url.Action("Insert", "AdminImageDestination")" >Thêm mới hình ảnh điểm đến</a></li>
    </ul>
    <!--maintabmenu-->

    <div class="notification msgsuccess" style="display: none" id="nofSuccess">
        <a class="close"></a>
        <p id="msgNofSuccess">This is a success message.</p>
    </div>
    <!-- notification msgsuccess -->

    <div class="notification msgerror" style="display: none" id="nofError">
        <a class="close"></a>
        <p id="msgNofError">This is an error message.</p>
    </div>
    <!-- notification msgerror -->
    
     @using (Html.BeginForm("Insert", "AdminImageDestination", FormMethod.Post, new { @id = "formCreate", @class = "stdform stdform2", enctype = "multipart/form-data" }))
     {
         
             
         @Html.ValidationSummary()
       
         <input type="hidden" name="IdDestination" value="@ViewBag.IdDestination" />
      
            <div class="contenttitle radiusbottom0">
            <h2 class="table"><span>Thông tin hình ảnh điểm đến</span></h2>
        </div>
       
         <p>
             <label>Chọn hình ảnh</label>
             <span class="field">
                 <input type="file" id="Image" name="Image" />
             </span>
         </p>        
          <p>
            <label>Vị trí</label>
            <span class="field">
                @Html.TextBoxFor(model => model.Position)
            </span>
        </p>
        <p class="stdformbutton">
            <input type="submit" value="Chấp nhận" onclick="return checkField()" />
            <input type="submit" value="Trở về" onclick="javascript: history.back(); return false" />
        </p>

     }

    <br clear="all" />

</div>


